package com.gao.file;

import java.io.File;
import java.util.Scanner;

/**
 * @Author: ShanYuqing
 * @Version: v1.0
 */
public class FileTest {
    public static void main(String[] args) {
        File file = getFile();
        System.out.println(file);
    }
    public static File getFile(){
        Scanner sc= new Scanner(System.in);
        System.out.println("请输入文件夹路径：");
        while (true) {
            String s = sc.nextLine();
            File dir = new File(s);
            if(!dir.exists()){
                System.out.println("您输入的文件夹路径不存在，请重新输入：");
            } else if (dir.isFile()) {
                System.out.println("您输入的是文件路径，请重新输入：");
            }else{
                return dir;
            }
        }
    }
}
